<template>
	
	 
	<el-table class="mb20" :data="tableData" border style="width: 100%">
		<el-table-column prop="name" label="性名" />
		<el-table-column prop="orders" label="排序" />
		
		<el-table-column label="操作">
			<template #default="scope">
				<el-button size="mini"
					@click="edit({row:scope.row,index:scope.$index}, ()=>{scope.row.pid = scope.row.pid == 0 ? scope.row.pid + '' : + scope.row.pid})">
					编辑</el-button>
			</template>
		</el-table-column>
	</el-table>
	<!-- <el-pagination background layout="prev, pager, next" :total="1000">
	</el-pagination> -->
	<el-dialog v-model="modalState" title="成员">
		<el-form :model="form" ref="rule" :rules="rules">
			<el-form-item label="性名"  prop="name" :label-width="formLabelWidth">
				<el-input v-model="form.name" autocomplete="off"></el-input>
			</el-form-item>
			<el-form-item label="排序"  prop="name" :label-width="formLabelWidth">
				<el-input v-model="form.orders" autocomplete="off"></el-input>
			</el-form-item>
			
			

		</el-form>
		<template #footer>
			<span class="dialog-footer">
				<el-button @click="modalState = false">取消</el-button>
				<el-button type="primary" @click="submit('rule')">确定</el-button>
			</span>
		</template>
	</el-dialog>
</template>

<script lang="ts">
	import {
		ElMessageBox,
		ElMessage
	} from 'element-plus'
	export default {
		data() {
			return {
				formLabelWidth: '120px',
				form: {
					name: '',
					orders: '',
					jianjie:""
				},
				rules: {
				        
				},
				pid: []
			}
		},
		mounted() {
			this.getData();
		},
		methods: {

			getData() {
				this.$http.post("/index.php/index/Goods/jslists").then(data => {
					this.tableData = data;
					

				})
			},
			submit(ref) {
				console.log(this.$refs)
				this.doRules(this.$refs[ref]).then(()=>{
					if (this.id) this.form.id = this.id;
					this.form.image = "";
					this.$http.post(this.id ? '/index.php/index/Goods/jsedits' : "/index.php/index/Englishhdapi/jsadd",
						this.form).then(data => {
						console.log(data)
						this.modalState = false;
						ElMessage({
							message: this.id ? '编辑成功' : '新增成功',
							type: 'success',
						})
						this.getData();
					})
				})
				
			},
			remove(data){
				this.$http.post("/index.php/index/Englishhdapi/jsdel",{id:data.row.id}).then(data => {
					ElMessage({
						message: '删除成功' ,
						type: 'success',
					})
					this.getData();
				})
			},
			handleAvatarSuccess(file) {

				this.form.image = file.data;
			},
			


		}
	}
</script>
